Add copy-last command to copy assistant messages to clipboard#583
Open
backnotprop wants to merge 2 commits intomainfrom
Open
Add copy-last command to copy assistant messages to clipboard#583backnotprop wants to merge 2 commits intomainfrom
backnotprop wants to merge 2 commits intomainfrom
Conversation
Copies the last rendered assistant message to the system clipboard. Reuses the annotate-last session-log lookup (PPID → CWD slug → ancestor walk for Claude Code; CODEX_THREAD_ID for Codex; session dir for Copilot CLI) but skips the UI and writes straight to the clipboard. - Adds cross-platform clipboard helper (pbcopy / clip.exe / wl-copy, xclip, xsel fallback / clip.exe under WSL) - Adds `plannotator copy-last` and `plannotator copilot-copy-last` subcommands - Registers the /plannotator-copy-last slash command in the Claude Code and Copilot plugins plus all three install scripts and their tests
Registers the Pi command that mirrors /plannotator-copy-last in the Claude Code and Copilot CLI plugins. Pi runs on Node, so the clipboard helper was refactored to drop its Bun.file dependency (inline WSL detection via fs.readFileSync) and vendored into apps/pi-extension/ generated/ via vendor.sh — the same reuse pattern used for other shared server utilities. The Pi handler reads the last assistant message from the session manager (same source as /plannotator-last) and writes it to the system clipboard, surfacing success / failure through ctx.ui.notify.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a new
copy-lastcommand that copies the last rendered assistant message to the system clipboard, complementing the existingannotate-lastfunctionality. The command works across Claude Code, Copilot CLI, and other integrations without opening any UI.Key Changes
New clipboard utility (
packages/server/clipboard.ts): Cross-platform clipboard support for macOS (pbcopy), Windows (clip.exe), WSL, and Linux (wl-copy/xclip/xsel)Two new CLI modes in
apps/hook/server/index.ts:copy-last: Copies the last message from standard Plannotator sessions using the same lookup logic asannotate-lastcopilot-copy-last: Copies the last message from Copilot CLI sessionsNew slash commands:
/plannotator-copy-lastfor Claude Code (in both hook and copilot apps)Updated CLI help and tests: Added
copy-lastto the help text and updated test assertions to verify the new command files are installedImplementation Details
copy-lastcommand reuses the existing message lookup infrastructure (getLastRenderedMessage,getLastCodexMessage,getLastCopilotMessage) to find the target messagehttps://claude.ai/code/session_01J3fNDB7ika2PdUdRMdrmHp